//
//  SAElementType.h
//  GameFrame
//
//  Created by MOSS on 2013/11/20.
//  Copyright (c) 2013年 Hiroshi Nomura. All rights reserved.
//

#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>

#ifndef GameFrame_SAElementType_h
#define GameFrame_SAElementType_h

typedef struct _Vector2D {
	GLfloat x;
	GLfloat y;
} Vector2D;

typedef struct _Vector3D {
	GLfloat x;
	GLfloat y;
	GLfloat z;
} Vector3D;

typedef struct _Vector4D{
	GLfloat x;
	GLfloat y;
	GLfloat z;
	GLfloat w;
}Vector4D;

typedef GLfloat  Matrix4x4[16];

typedef Vector3D Vertex;
typedef Vector3D Normal;
typedef Vector3D Texture;
typedef GLshort  JointIndex[4];
typedef GLfloat	 VertexWeight[4];

typedef struct __RenderedVertex{
    Vertex* vertex;
    GLuint vertexCount;
    GLsizei vertexSize;
    
    Texture* textureCoord;
    GLuint textureCoordCount;
    GLsizei textureCoordSize;
    
    Normal* normal;
    GLuint normalCount;
    GLsizei normalSize;
    
    GLushort* element;
    GLuint elementCount;
    GLsizei elementSize;
}RenderedVertex;

typedef struct _TextureImage{
	GLubyte *data;
	GLsizei size;
	
	GLuint	width;
	GLuint	height;
	GLuint	rowByteSize;
	GLenum	format;
}TextureImage;

typedef struct __Pose{
    Vector3D    translate;
    Vector3D    scale;
    Vector4D    quaternion;
}Pose;

typedef struct __SkinVertex{
    VertexWeight* vertexWeight;
    GLuint vertexWeightCount;
    GLsizei vertexWeightSize;
    
    JointIndex* jointIndex;
    GLuint jointIndexCount;
    GLsizei jointIndexSize;
}SkinVertex;

typedef struct __Joint{
    char*           jointName;
    GLuint          jointId;
    struct __Joint* parent;
    
    //multiply current localPose to parent localPose to translate origin pose
    Pose           localPose;
    Matrix4x4      globalPoseMatrix;
    Matrix4x4      inverseBindPoseMatrix;
    
    GLboolean   hasInfluencedParent;
}Joint;

typedef struct __Skeleton{
    Joint*  jointArray;
    GLsizei jointCount;
}Skeleton;

#endif
